From d4cc5cbac63a42945eabbb8790f2edd5a9188932 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 14 May 2003 18:50:27 +0000 Subject: [PATCH] Add EasyGPS binary format based on info from Eric Cloninger. --- gpsbabel/Makefile | 6 ++-- gpsbabel/README | 12 ++++++++ gpsbabel/reference/easygps.loc | Bin 0 -> 1378 bytes gpsbabel/testo | 9 ++++++ gpsbabel/util.c | 54 +++++++++++++++++++++++++++------ gpsbabel/vecs.c | 7 +++++ 6 files changed, 76 insertions(+), 12 deletions(-) create mode 100755 gpsbabel/reference/easygps.loc diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index 2eb64295f..ec7bcef8a 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -5,7 +5,7 @@ INSTALL_TARGETDIR=/usr/local/ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o \ gpsutil.o pcx.o cetus.o copilot.o gpspilot.o magnav.o \ psp.o holux.o garmin.o tmpro.o tpg.o \ - xcsv.o gcdb.o tiger.o internal_styles.o + xcsv.o gcdb.o tiger.o internal_styles.o easygps.o FILTERS=position.o duplicate.o @@ -55,8 +55,8 @@ dep: (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e "\t./mkstyle.sh > internal_styles.c" ) >> /tmp/dep echo Edit Makefile and bring in /tmp/dep -VERSIONU=1_1_1_beta00508003 -VERSIOND=1.1.1_beta00508003 +VERSIONU=1_1_1_beta00514003 +VERSIOND=1.1.1_beta00514003 release: rm -fr gpsbabel-$(VERSIOND) cvs tag gpsbabel_$(VERSIONU) diff --git a/gpsbabel/README b/gpsbabel/README index 16f006a53..0fdaae593 100644 --- a/gpsbabel/README +++ b/gpsbabel/README @@ -305,6 +305,18 @@ THE FORMATS http://xcski.com/~ptomblin/CoPilot/ http://navaid.com/CoPilot/ + EasyGPS + + This is the binary file format used by EasyGPS. This format is + seemingly being phased out in favor of GPX in newer versions of + EasyGPS, but this allows conversions to and from the old binary + .loc format. + + http://www.easygps.com/ + + Information about and sketchy code to implement this file format + were provided by Eric Cloninger. + DATA FILTERS diff --git a/gpsbabel/reference/easygps.loc b/gpsbabel/reference/easygps.loc new file mode 100755 index 0000000000000000000000000000000000000000..011dd965370c8375164bd34576cc0955f1787d8b GIT binary patch literal 1378 zcmbu<&ui0Q7zgld{)$tF7dac=EL{-zR6+RMylsx zkfCMd5^4gC7#Jj}<=LcGcY!DfBFIsT>Ncv9GXsN#zBPI>t*ZQS+A>{4OrVkm2E!PQ zV-u7-;IteMN>Ji1-{Lr~+MbeKgBN)#al3YuTq)IxMBi6S*^UKcq+z14ZKgM4Z=7WOM10%P}kB`4oTKzqp#k zlX>vv+r-0=n7AAZibqsLiOetAb8SC$ee%-F K|8V`IPTWu3Homa{ literal 0 HcmV?d00001 diff --git a/gpsbabel/testo b/gpsbabel/testo index 4c218bb8f..cdfc4cd19 100755 --- a/gpsbabel/testo +++ b/gpsbabel/testo @@ -291,3 +291,12 @@ ${PNAME} -i copilot -f reference/UKultralight.pdb -o copilot -F ${TMPDIR}/cop.pd ${PNAME} -i copilot -f reference/UKultralight.pdb -o gpx -F ${TMPDIR}/cop1.gpx ${PNAME} -i copilot -f ${TMPDIR}/cop.pdb -o gpx -F ${TMPDIR}/cop2.gpx compare ${TMPDIR}/cop1.gpx ${TMPDIR}/cop2.gpx + +# +# EasyGPS. Another binary format. +# +rm -f ${TMPDIR}/easy.loc +${PNAME} -i easygps -f reference/easygps.loc -o easygps -F ${TMPDIR}/ez.loc +${PNAME} -i easygps -f reference/easygps.loc -o gpx -F ${TMPDIR}/ez1.gpx +${PNAME} -i easygps -f ${TMPDIR}/ez.loc -o gpx -F ${TMPDIR}/ez2.gpx +compare ${TMPDIR}/ez1.gpx ${TMPDIR}/ez2.gpx diff --git a/gpsbabel/util.c b/gpsbabel/util.c index 359e6f2c2..d67de4063 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -24,6 +24,9 @@ #include #include +static int i_am_little_endian = -1; +static int doswap(void); + #ifdef DEBUG_MEM #define DEBUG_FILENAME "/tmp/gpsbabel.debug" @@ -173,7 +176,20 @@ xstrappend(char *src, const char *new) return src; } +/* + * Duplicate a pascal string into a normal C string. + */ +char * +pstrdup(char *src) +{ + int len = src[0]; + char *obuf = xmalloc(len + 1); + memcpy(obuf, src + 1, len); + obuf[len] = 0; + + return obuf; +} void rtrim(char *s) @@ -296,6 +312,28 @@ le_read32(void *addr) return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); } +/* + * Read a little-endian 64-bit value from 'src' and return it in 'dest' + * in host endianness. + */ +void +le_read64(void *dest, void *src) +{ + char *cdest = dest; + char *csrc = src; + + doswap(); /* make sure i_am_little_endian is initialized */ + + if (i_am_little_endian) { + memcpy(dest, src, 8); + } else { + int i; + for (i = 0; i < 7; i++) { + cdest[i] = csrc[7-i]; + } + } +} + void le_write16(void *addr, unsigned value) { @@ -373,11 +411,9 @@ get_cache_icon(const waypoint *waypointp) return NULL; } -static int swapit = -1; - static int doswap() { - if (swapit < 0) + if (i_am_little_endian < 0) { /* On Intel, Vax and MIPs little endian, -1.0 maps to the bytes 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f and on Motorola, @@ -387,9 +423,9 @@ static int doswap() double d = 1.0; char c[8]; memcpy(c, &d, 8); - swapit = (c[0] == 0); + i_am_little_endian = (c[0] == 0); } - return swapit; + return i_am_little_endian; } double @@ -398,10 +434,10 @@ pdb_read_double(void* ptr) double ret; char r[8]; int i; - doswap(); /* make sure swapit is initialized */ + doswap(); /* make sure i_am_little_endian is initialized */ for (i = 0; i < 8; i++) { - int j = (swapit)?(7-i):i; + int j = (i_am_little_endian)?(7-i):i; r[i] = ((char*)ptr)[j]; } memcpy(&ret, r, 8); @@ -415,10 +451,10 @@ pdb_write_double(void* ptr, double d) int i; memcpy(r, &d, 8); - doswap(); /* make sure swapit is initialized */ + doswap(); /* make sure i_am_little_endian is initialized */ for (i = 0; i < 8; i++) { - int j = (swapit)?(7-i):i; + int j = (i_am_little_endian)?(7-i):i; *(char*)ptr++ = r[j]; } return; diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index 9540dcc70..26ba02fb8 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -49,6 +49,7 @@ extern ff_vecs_t tpg_vecs; extern ff_vecs_t magnav_vec; extern ff_vecs_t tmpro_vecs; extern ff_vecs_t gcdb_vecs; +extern ff_vecs_t easygps_vecs; static vecs_t vec_list[] = { @@ -167,6 +168,12 @@ vecs_t vec_list[] = { "U.S. Census Bureau Tiger Mapping Service", NULL }, + { + &easygps_vecs, + "easygps", + "EasyGPS", + NULL + }, { NULL, NULL, -- 2.30.2